package storage;

import java.util.Stack;
import java.util.logging.Logger;

public class RedoStorage {
	private static Stack<UndoRedoDetails> stack_ = new Stack<UndoRedoDetails>();
	private static String status_ = "new command";
	private final static Logger LOGGER = Logger.getLogger(RedoStorage.class
			.getName());

	// POP //
	public static UndoRedoDetails getLastest() {
		if (stack_.empty()) {
			return null;
		} else if (!stack_.empty()) {
			return stack_.pop();
		} else {
			return null;
		}
	}

	// PUSH //
	public static void storeDetails(UndoRedoDetails details) {
		stack_.push(details);
	}

	// PEEK //
	public static UndoRedoDetails peekLastest() {
		return stack_.peek();
	}

	public static boolean isEmpty() {
		return stack_.empty();
	}

	public static void clear() {
		// to be used every time program just starts or end
		// and after a new command is received (from user)
		while (!stack_.empty()) {
			stack_.pop();
		}
		assert stack_.empty();
	}

	public Object clone() {
		try {
			return super.clone();
		} catch (CloneNotSupportedException e) {
			return null;
		}
	}
}
